﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Sauces.Bussinees.Entities.Caja;
using Sauces.Bussinees.Entities.Almacen;
using Sauces.Bussinees.Logic.Service;
using Sauces.Bussinees.Logic.Caja.Service;
using Microsoft.Practices.Unity;
using System.Web.ModelBinding;

namespace Sauces.Web.Caja
{
    public partial class FrmListaBoleta : System.Web.UI.Page
    {
        [Dependency]
        public IBoletaService BoletaService { get; set; }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            var opc = Request.QueryString["opc"];
            var IdBoleta = Request.QueryString["id"];

            if (opc != null && opc == "delete" && IdBoleta != null)
            {
                var id = Int32.Parse(IdBoleta.ToString());
                BoletaService.removeBoleta(id);
            }
        }

        public IEnumerable<Boleta> GetBoletas([Control("txtCriterio")] string criterio,
                                      [Control("txtFechaInicio")] DateTime? fechaIni,
                                      [Control("txtFechaFin")]DateTime? fechaFin)
        {
            return BoletaService.getAllBoletaByNombreAndFechas(criterio, fechaIni, fechaFin);
        }

    }
}